package edu.zut.cs.software.perfect.grade.service;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import edu.zut.cs.software.perfect.base.service.GenericGenerator;
import edu.zut.cs.software.perfect.grade.domain.CourseGrade;
import edu.zut.cs.software.perfect.grade.domain.StudentGrade;

/**
 * @ClassName CourseGradeEntityGenerator
 * @Description TODO
 * @Author zhangwenkai
 * @Date 2020年5月30日 上午12:08:25
 * @Version 1.0
 */
public class CourseGradeEntityGenerator extends GenericGenerator {
	
	StudentGradeManager studentGradeManager;
	
	CourseGradeManager courseGradeManager;

	@Autowired
	public void setStudentGradeManager(StudentGradeManager studentGradeManager) {
		this.studentGradeManager = studentGradeManager;
	}

	@Autowired
	public void setCourseGradeManager(CourseGradeManager courseGradeManager) {
		this.courseGradeManager = courseGradeManager;
	}
	@Test
	public void testBuild() {
		int num_courseGrade = 3;
		int num_studentGrade = 3;
		for(int i = 1;i < num_courseGrade;i++) {
			CourseGrade courseGrade = new CourseGrade();
			courseGrade.setCourseName("系别"+i);
			courseGrade.setCourseCode("XCode_"+i);
			this.courseGradeManager.save(courseGrade);
			for(int j = 1;j < num_courseGrade;j++) {
				CourseGrade c = new CourseGrade();
				c.setCourseName("课程"+i+"_"+j);
				c.setCourseCode("KCode_"+i+"_"+j);
				c.setParent(courseGrade);
				courseGrade = this.courseGradeManager.save(c);
				for(int k = 1; k < num_studentGrade;k++) {
					StudentGrade studentGrade = new StudentGrade();
					studentGrade.setStudentName("学生"+i+"_"+j+"_"+k);
					studentGrade.setStudentId("SId_"+i+"_"+j+"_"+k);
					studentGrade.setCourseCode("课程"+i+"_"+j);
					studentGrade.setCourseName("KCode_"+i+"_"+j);
					studentGrade.setCourseGrade(c);	
					studentGrade.setUsualSorce(90+k);
					studentGrade.setFinalSorce(90+k);
					studentGrade.setTotalSorce(90+k);
					studentGrade.setCourseGrade(c);
					studentGrade.setCourseGrade(courseGrade);
					this.studentGradeManager.save(studentGrade);
				}
				
				
			}
		}
	}
	
	

}
